package org.zjx.operation;

/**
 * 窗口操作函数式接口
 * 用于定义类型安全的窗口操作
 */
@FunctionalInterface
public interface WindowOperation<T> {

    /**
     * 执行操作
     * @param executor 操作执行器
     * @return 操作结果
     */
    T execute(OperationExecutor executor);

    // ========== 常用操作快捷方法 ==========

    /**
     * 点击操作
     */
    static WindowOperation<Void> click(int x, int y) {
        return executor -> {
            executor.click(x, y);
            return null;
        };
    }

    /**
     * 输入文本操作
     */
    static WindowOperation<Void> type(String text) {
        return executor -> {
            executor.type(text);
            return null;
        };
    }

    /**
     * 按键操作
     */
    static WindowOperation<Void> press(int keyCode) {
        return executor -> {
            executor.press(keyCode);
            return null;
        };
    }

    /**
     * 热键操作
     */
    static WindowOperation<Void> hotkey(int... keyCodes) {
        return executor -> {
            executor.hotkey(keyCodes);
            return null;
        };
    }

    static WindowOperation<Void> move(int x,int y){
        return executor -> {
            executor.move(x, y);
            return null;
        };
    }


    static WindowOperation<Void> gameMove(int x,int y){
        return executor -> {
            executor.gameMove(x, y);
            return null;
        };
    }

    static WindowOperation<Void> delay(long milliseconds) {
        return  executor -> {
            executor.delay(milliseconds);
            return null;
        };
    }
}